module.exports = app => {
  const { STRING, INTEGER, DECIMAL, DATE, TEXT, TINYINT } = app.Sequelize;

  const CoverShift = app.model.define('cover_shift', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    user_id: {
      type: INTEGER,
      allowNull: true,
      comment: '用户ID',
    },
    location: {
      type: STRING,
      allowNull: true,
      defaultValue: '',
      comment: '门店位置',
    },
    is_recruit: {
      type: TINYINT,
      allowNull: true,
      defaultValue: 1,
      comment: '是否招聘',
    },
    type_of_meal_id: {
      type: STRING,
      allowNull: true,
      comment: '餐饮类型',
    },
    cuisine_ids: {
      type: STRING,
      allowNull: true,
      comment: '菜系',
    },
    position_id: {
      type: INTEGER,
      allowNull: true,
      comment: '岗位',
    },
    price_of_day: {
      type: DECIMAL(10, 2),
      allowNull: true,
      comment: '工资/天',
    },

    connect_phone: {
      type: STRING,
      allowNull: true,
      comment: '联系电话',
    },
    remark: {
      type: STRING,
      allowNull: true,
      comment: '备注',
    },
    work_start_time: {
      type: DATE,
      allowNull: true,
    },
    work_end_time: {
      type: DATE,
      allowNull: true,
    },
    has_siesta_time: {
      type: TINYINT,
      allowNull: true,
      comment: '是否有午休时间',
    },
    has_night_home: {
      type: STRING,
      allowNull: true,
      comment: '是否有夜间休息室',
    },
    work_experience_id: {
      type: STRING,
      allowNull: true,
      comment: '工作年限',
    },

    work_environment_files: {
      type: TEXT,
      allowNull: true,
      comment: '工作环境',
    },
    personal_introduction: {
      type: TEXT,
      allowNull: true,
      comment: '个人介绍',
    },
    status: {
      type: TINYINT,
      allowNull: true,
      defaultValue: 1,
      comment: '',
    },
    del_flag: {
      type: INTEGER,
      allowNull: true,
      defaultValue: 0,
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    tableName: 'cover_shifts',
    timestamps: true,
  });

  CoverShift.associate = function() {
    // 定义与用户的关联关系
    app.model.CoverShift.belongsTo(app.model.User, { foreignKey: 'user_id' });
    app.model.CoverShift.belongsTo(app.model.Position, { foreignKey: 'position_id', as: 'position' });
    app.model.CoverShift.belongsTo(app.model.DictionaryDetail, { foreignKey: 'work_experience_id', as: 'workExperience' });
  };

  return CoverShift;
};
